#pragma once
#include <fstream>
#include <iostream>
using namespace std;
const int MEMORYSIZE = 20000;
const int POINTERSIZE = 100;
const int BLOCKSIZE = 2;
const int PHISICALMEMORY = MEMORYSIZE / BLOCKSIZE;
const int DELAY = 50;

class MemoryMenager
{
private:
	typedef enum Action {MEM_ALLOCATE,MEM_FREEALL,MEM_NOTVALID};
	
	typedef struct {
		enum Action MemoryAction;
		int Serial;
	}MemoryStruct;
	
protected:

		short int  Memory[PHISICALMEMORY]; 
		short int *Pointer[POINTERSIZE];
		short int * pFreeSame;			//main pointer to the first free space;

		 ifstream  MemoryFile;
		 char *MemoryFileName;
		 int i_Alloc,i_Free;
		 
		 void mem_Allocate(int Serial);
		 void mem_Free(int Serial);

public:

	 MemoryMenager(char * FN);
	~MemoryMenager();

	 MemoryStruct getNextAction();
	 void setName(char *FN);

	 void Initialize();

	 void Run();

	 virtual void Draw(int s,int stage) ;


};
